//
//  ShareUtil.swift
//  Runner
//
//  Created by HuiLu on 2019/12/16.
//  Copyright © 2019 The Chromium Authors. All rights reserved.
//

import Foundation

class ShareUtil: NSObject {
    static let shareUtil = ShareUtil()
    private override init() {
        super.init()
    }
    
    public func shareUrlBySystem(controller: UIViewController, url: String){
//        let textToShare = "xx"
//        let imageToShare = UIImage.init(named: "img_01")
        let urlToShare = NSURL.init(string: url)
//        let items = [textToShare,imageToShare ?? "WeShare",urlToShare ?? "WeShare"] as [Any]
        let items = [urlToShare] as [Any]
        let activityVC = UIActivityViewController(activityItems: items, applicationActivities: nil)
        //表示去掉不想显示的按钮  即第一点里面所包含的type 放到这里
        activityVC.excludedActivityTypes = [UIActivity.ActivityType.print]
        activityVC.completionWithItemsHandler =  { activity, success, items, error in

        }
         controller.present(activityVC, animated: true, completion: { () -> Void in
             
         })
    }
}
